﻿<UserControl x:Class="Seesmic.HelloTipi.Controls.PhotosTemplate"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"             
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
    xmlns:c="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"       
             xmlns:helpers="clr-namespace:Seesmic.HelloTipi.Helpers"
    mc:Ignorable="d"
    d:DesignHeight="600" d:DesignWidth="300">
    <UserControl.Resources>
        <helpers:FamilyToHeightConverter x:Key="FamilyToHeightConverter"/>
        <helpers:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
        <helpers:BoolToVisibilityReverseConverter x:Key="BoolToVisibilityReverseConverter"/>

        <DataTemplate x:Key="PhotosItemTemplate">
            <Image Width="82" Source="{Binding url_small}" />
        </DataTemplate>

        <ItemsPanelTemplate x:Key="PhotosItemPanel">
            <controls:WrapPanel/>
        </ItemsPanelTemplate>
    </UserControl.Resources>

    <Border Background="#B0151619"
                Margin="0,0,0,1"
                BorderBrush="#151619"
                BorderThickness="1,0,1,0">
        <Border>
            <Grid x:Name="item">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" MinHeight="220" MaxHeight="400" />
                    <RowDefinition Height="100" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="35"/>
                </Grid.RowDefinitions>

                <!-- Picture -->
                <!--<StackPanel Orientation="Vertical" Margin="0">-->
                <Image MinHeight="216" MaxHeight="400"  MinWidth="288" x:Name="ImageSelected" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="0" Margin="5,5,5,0" Stretch="Uniform" DataContext="{Binding ElementName=lbPhotos, Path=SelectedItem}" Source="{Binding url_medium}"/>
                <!--<ProgressBar x:Name="pbDownload" DataContext="{Binding pbDownload}" Minimum="{Binding Minimum}" Maximum="{Binding Maximum}" Value="{Binding Value}" Margin="0" Width="288" Height="6" Foreground="#FF9DC123" BorderThickness="0" Background="#B0151619" UseLayoutRounding="False"/>
                </StackPanel>-->

                <!-- Buttons -->
                <Border Grid.Row="1" CornerRadius="4" Margin="5"  BorderThickness="0,1,0,1" >
                    <Border.BorderBrush>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                            <GradientStop Color="#585C61" Offset="0" />
                            <GradientStop Color="#000000" Offset="1" />
                        </LinearGradientBrush>
                    </Border.BorderBrush>
                    <Border.Background>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                            <GradientStop Color="#44484E" Offset="0" />
                            <GradientStop Color="#17181B" Offset="1" />
                        </LinearGradientBrush>
                    </Border.Background>
                    <StackPanel Orientation="Vertical" Margin="0,5,0,0">

                        <StackPanel Orientation="Horizontal" Margin="2" Grid.Row="0">
                            <Button HorizontalAlignment="Center" DataContext="{Binding AddtoFavoriteCommand}" Content="{Binding}" Command="{Binding}" Width="140" Margin="2,0,0,0"/>
                            <Button HorizontalAlignment="Center" DataContext="{Binding UploadPhotoCommand}" Content="{Binding}" Command="{Binding}" Width="140" />
                        </StackPanel>

                        <StackPanel Orientation="Vertical" Margin="2" Grid.Row="1">
                            <TextBox x:Name="PhotoComment" Width="280" Text="{Binding Comment, Mode=TwoWay}"/>
                            <StackPanel Orientation="Horizontal" Margin="2" Grid.Row="0">
                                <Button HorizontalAlignment="Center" DataContext="{Binding CommentPhotoCommand}" Content="{Binding}" Command="{Binding}" Width="140" Margin="2,0,0,0"/>
                                <Button HorizontalAlignment="Center" DataContext="{Binding DownloadPhotoCommand}" Content="{Binding}" Command="{Binding}" Width="140"/>
                            </StackPanel>
                        </StackPanel>
                    </StackPanel>
                </Border>

                <Grid Grid.Row="2">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="{Binding family, Converter={StaticResource FamilyToHeightConverter}, ConverterParameter=25}"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <ComboBox x:Name="Albums" Grid.Row="0" Margin="5,2,5,0" ItemsSource="{Binding Albums}" DisplayMemberPath="name" SelectedValuePath="id" SelectedItem="{Binding SelectedAlbum, Mode=TwoWay}" VerticalContentAlignment="Top" HorizontalContentAlignment="Stretch" IsSynchronizedWithCurrentItem="False" />
                    <!--SelectedIndex="{Binding SelectedAlbumIndex, Mode=TwoWay}"-->
                    <ListBox Background="#B0151619" Grid.Row="1" IsSynchronizedWithCurrentItem="False" SelectedItem="{Binding PhotoSelected, Mode=TwoWay}" ItemsSource="{Binding PhotosCollection}" x:Name="lbPhotos" Margin="5,0,5,0" SelectionMode="Single" ItemTemplate="{StaticResource PhotosItemTemplate}" ItemsPanel="{StaticResource PhotosItemPanel}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto" Cursor="Hand" LayoutUpdated="lbPhotos_LayoutUpdated" />
                </Grid>

                <!-- Buttons -->
                <Border Grid.Row="3" CornerRadius="0,0,4,4" Margin="5,0,5,5"  BorderThickness="0,1,0,1" >
                    <Border.BorderBrush>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                            <GradientStop Color="#585C61" Offset="0" />
                            <GradientStop Color="#000000" Offset="1" />
                        </LinearGradientBrush>
                    </Border.BorderBrush>
                    <Border.Background>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                            <GradientStop Color="#44484E" Offset="0" />
                            <GradientStop Color="#17181B" Offset="1" />
                        </LinearGradientBrush>
                    </Border.Background>
                    <Grid>
                        <StackPanel Orientation="Horizontal" Margin="5,0,5,2" Grid.Row="1">
                            <Button HorizontalAlignment="Center" DataContext="{Binding DownloadAlbumCommand}" Content="{Binding}" Command="{Binding}" Margin="0" />
                            <ProgressBar DataContext="{Binding pbTraitement}" x:Name="pbTraitement" Minimum="{Binding Minimum}" Maximum="{Binding Maximum}" Value="{Binding Value}" Margin="2" Height="20" Width="140" Foreground="#FF7F9A31" BorderThickness="0" Background="#B0151619" UseLayoutRounding="False"/>
                        </StackPanel>
                    </Grid>
                </Border>
            </Grid>
        </Border>
    </Border>
</UserControl>
